<!--
 * @Author: 码上talk|RC
 * @Date: 2021-09-24 10:19:19
 * @LastEditTime: 2021-09-24 11:28:22
 * @LastEditors: 码上talk|RC
 * @Description: 
 * @FilePath: /ma-portal/components/picker/group-leader.vue
 * @微信:  13680065830
 * @邮箱:  3189482282@qq.com
 * @oops: Just do what I think it is right
-->
<template>
  <van-picker class="group-leader" 
    ref="picker" show-toolbar 
    :columns="leaderList"
    @confirm.native="handleConfirm"
    @cancel.native="handleCancel">
  </van-picker>
</template>

<script>
  import {
    model
  } from '@/model';

  const {
    Member
  } = model.collection
  export default {
    name: 'GroupLeader',
    components: {},
    mixins: [],
    props: {},
    data() {
      return {
        params:{
          pageIndex:1,
          pageSize:100
        },
        leaderList:[]
      }
    },
    computed: {
      picker() {
        return this.$refs.picker
      }
    },
    created() {
      this.getPage()
    },
    methods: {
      getPage() {
        return Member.sendApi('page', {
          params: this.params,
          data: {
            query: {
              isTeamLeader: 1
            }
          }
        }).then((res) => {
          if (res.status) {
            const {
              data
            } = res
            data.forEach(item => {
              item.text = item.nickname
              this.leaderList.push(item)
            })
          }
          return res
        })
      },
      handleConfirm(e) {
        let { value } = e.detail
        this.$emit('confirm', value)
      },
      handleCancel() {
        this.$emit('cancel')
      }
    }
  }
</script>